package com.geely.design.pattern.behavioral.state;

public class CourseVideoContext {

    public final static CourseVideoState PLAY_STATE = new PlayState();
    public final static CourseVideoState STOP_STATE = new StopState();
    public final static CourseVideoState SPEED_STATE = new SpeedState();
    public final static CourseVideoState PAUSE_STATE = new PauseState();

    private CourseVideoState courseVideoState;

    public CourseVideoState getCourseVideoState() {
        return courseVideoState;
    }

    public void setCourseVideoState(CourseVideoState courseVideoState) {
        this.courseVideoState = courseVideoState;
        // 关键的一行代码, 给上下文对象设置 视频状态的同时, 将上下文对象传给视频状态,
        // 从而让视频状态对象有了改变上下文对象的状态的功能
        this.courseVideoState.setCourseVideoContext(this);
    }

    public void play() {
        this.courseVideoState.play();
    }
    public void stop() {
        this.courseVideoState.stop();
    }
    public void speed() {
        this.courseVideoState.speed();
    }
    public void pause() {
        this.courseVideoState.pause();
    }

}
